home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_559 / apig / apiglib_v11.lzh / e6_requesters.rexx < prev    next >
OS/2 REXX Batch file  |  1991-09-28  |  5KB  |  162 lines

  1. /*  Example Using Requesters  */
  2.  
  3. /*  */
  4. x = addlib("apig.library",0,-30,0)
  5.  
  6. portname = "examplereq6_port"
  7. p = openport(portname)
  8. call set_apig_globals()
  9. scrtitle = "Hey Buddy, Yea You,  This is Your New Screen  !"
  10. wintitle = "This is your title"
  11. winidcmp = CLOSEWINDOW+MENUPICK
  12. winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO+ACTIVATE
  13.  
  14. scr = openscreen(0,0,640,400,3,4,5,LACE+HIRES,CUSTOMSCREEN,scrtitle)
  15.  
  16. /* open window */
  17. call setrgb4(scr,0,3,3,3)
  18. call setrgb4(scr,1,0,0,0)
  19. call setrgb4(scr,2,0,0,7)
  20. call setrgb4(scr,3,15,15,0)
  21. call setrgb4(scr,4,15,5,1)
  22. call setrgb4(scr,5,0,8,15)
  23. call setrgb4(scr,6,0,15,0)
  24. call setrgb4(scr,7,6,5,4)
  25.  
  26. w1  = openwindow(portname,0,0,640,400,2,4,winidcmp,winflags,wintitle,scr,0,0,0) 
  27. rpw1 = getwindowrastport(w1) 
  28.  
  29. menustrip1 = makemenu(w1,"PICK ONE OF THESE",0,0,MENUENABLED,0)
  30. say "menu = " d2x(c2d(menustrip1))
  31.  
  32.   m0 = makeitem(w1,"UGLY SYSTEM REQUESTER",menustrip1,0,4,0,0,0,0,'A',6,3,JAM1,0,0)
  33.   m1 = makeitem(w1,"MY LITTLE REQUESTER  ",menustrip1,0,40,0,0,0,0,'A',6,3,JAM1,0,0)
  34.  
  35. call setmenustrip(w1,menustrip1)
  36.  
  37. menuitem0 = menunumber(menustrip1,menustrip1,m0,0)
  38. menuitem1 = menunumber(menustrip1,menustrip1,m1,0)
  39.  
  40.  
  41. /* My Little Requester */
  42.  
  43. g1 = makestrgadget(w1,20,50,320,11,GADGHCOMP,RELVERIFY+ENDGADGET,0,5,0,0,22,0,100)
  44. z  = setstrgad(g1,"Enter Something into this gadget")
  45.  
  46. gix  = makeitext(w1,"END REQ",AUTOLEFTEDGE,AUTOTOPEDGE,0,3,JAM2,0,0)
  47. gix1 = makeitext(w1,"THIS GADGET ENDS THE REQUEST",90,AUTOTOPEDGE,5,1,JAM2,0,gix)
  48. g2   = makeboolgadget(w1,10,90,67,12,GADGHCOMP,GADGIMMEDIATE+ENDGADGET,gix,5,0,0,26,g1)
  49.  
  50. giy  = makeitext(w1,"WON'T END IT",AUTOLEFTEDGE,AUTOTOPEDGE,1,5,JAM2,0,0)
  51. giy1 = makeitext(w1,"THIS GADGET DOES NOT END THE REQUEST",120,AUTOTOPEDGE,4,2,JAM2,0,giy)
  52. g3   = makeboolgadget(w1,10,110,106,12,GADGHCOMP,GADGIMMEDIATE,giy,5,0,0,27,g1)
  53.  
  54. giz  = makeitext(w1,"WILL FORCE ENDREQ",AUTOLEFTEDGE,AUTOTOPEDGE,0,3,JAM2,0,0)
  55. giz1 = makeitext(w1,"THIS GADGET CALLS ENDREQUEST() ",160,AUTOTOPEDGE,7,3,JAM2,0,giz)
  56. g4   = makeboolgadget(w1,10,130,145,12,GADGHCOMP,GADGIMMEDIATE,giz,5,0,0,28,g1)
  57.  
  58. /* the left & top edge of the itext is relative to the requester */
  59. i1x = makeitext(w1,"This is Your Requester Buddy",10,10,3,2,JAM2,0,0)
  60.  
  61. /* itext below gets linked to the one above */
  62. call makeitext(w1," The String Gadget Above Ends the Requester",20,70,3,2,JAM2,0,i1x)
  63.  
  64. req  = makerequester(w1,20,20,450,150,g1,i1x,0,4,0,0,0,0)
  65.  
  66.  
  67.  
  68. /* DMRequester */
  69. reqbitmap = loadiff("req6bitmap",w1)
  70. reqwidth  = iffwidth(reqbitmap)
  71. reqheight = iffheight(reqbitmap)
  72. req2g1 = makeboolgadget(w1,0,0,reqwidth,reqheight,GADGHCOMP,GADGIMMEDIATE+ENDGADGET,0,5,0,0,128,0)
  73. req2 = makerequester(w1,0,0,reqwidth,reqheight,req2g1,0,0,6,POINTREL+PREDRAWN,0,0,reqbitmap)
  74. call makeitext(w1,"This is Your Requester Buddy",10,10,1,2,JAM2,0,req2)
  75. x = setdmrequest(w1,req2)
  76.  
  77.  
  78.  
  79. /* --- auto request text --- */
  80.  
  81. bodytext = makeitext(w1,"This is Your Requester Buddy",10,10,1,5,JAM2,0,0)
  82. call makeitext(w1," Use one of the gadgets below ",10,21,1,5,JAM2,0,bodytext)
  83. call makeitext(w1,"   to end this requester",10,32,1,5,JAM2,0,bodytext)
  84. yestext = makeitext(w1," YES ",AUTOLEFTEDGE,AUTOTOPEDGE,AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,0,0)
  85. notext  = makeitext(w1," NO ",AUTOLEFTEDGE,AUTOTOPEDGE,AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,0,0)
  86.  
  87.  
  88. z = pitext(rpw1,50,50,"This is an example of using requesters",5,2,JAM2,0)
  89. z = pitext(rpw1,50,80,"  select a Requester from the MENU",5,2,JAM2,0)
  90. z = pitext(rpw1,50,110,"  ... or you can double-click the mouse Menu-Button",5,2,JAM2,0)
  91.  
  92. exitme = 0
  93. do forever
  94.      x = waitpkt(portname)
  95.   
  96.      do forever 
  97.   
  98.         msg = '0000 0000'x
  99.         msg = getpkt(portname)
  100.         if msg = '0000 0000'x then leave
  101.         class = getarg(msg,0)
  102.         if class = CLOSEWINDOW then exitme = 1
  103.         if class = MENUPICK then 
  104.           do
  105.              menselect = getarg(msg,1)
  106.              x = reply(msg,0)  
  107.              if menselect = menuitem1 then 
  108.                 do
  109.                    Y = request(req,w1)  
  110.                    if Y = 1 then call getreqresponse()
  111.                 end
  112.              else   
  113.              if menselect = menuitem0 then 
  114.                 do
  115.                    Y = autorequest(w1,bodytext,yestext,notext,0,0,450,100)
  116.                 end
  117.           end
  118.         else  
  119.            x = reply(msg,0)  
  120.      end  
  121.    if exitme = 1 then leave
  122.    
  123. end
  124.  
  125. x = cleardmrequest(w1)
  126. /* a = freemenu(menustrip1) */
  127. a = closewindow(w1)
  128. a = closescreen(scr)
  129.  
  130. exit
  131.  
  132. /* ----------------------------------------------------------------------- 
  133.    get intui-message from requester 
  134.    ----------------------------------------------------------------------- */
  135.  
  136. getreqresponse:
  137.  reqexit = 0
  138.  do forever
  139.      if reqexit ~= 0 then leave
  140.      x = waitpkt(portname)
  141.      do forever
  142.         msg = getpkt(portname)
  143.         if msg = '0000 0000'x then leave
  144.         class = getarg(msg,0)
  145.         say "Got Class " class
  146.         if class = REQCLEAR then reqexit = 1
  147.         if class = GADGETDOWN then 
  148.            do
  149.                if getarg(msg,9) = 28 then /* if gadid=28 force endrequest */
  150.                do
  151.                   say "Gagdet ID = " getarg(msg,9) "Forcing ENDREQUEST() "
  152.                   reqexit = endrequest(req,w1)
  153.                   end
  154.            end
  155.         rr = Reply(msg,0)   
  156. gggg = '0001 2000'
  157. act = activategadget(gggg,w1,req)
  158. say "activation = " act
  159.      end
  160.  end
  161. return 1
  162.